﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using QD.Utils;
using System.Diagnostics;

namespace DaZhong.app_code
{
  public  class AppConfig
    {
        public static Dictionary<string, string> Config = new Dictionary<string, string>();
        public static int StartTime { get; set; }
        public static int EndTime { get; set; }
        public static int ContentPicNum { get; set; }
        public static void Init()
        {

            try
            {
                Config.Clear();
                StreamReader sr = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "/config/config.ini", Encoding.UTF8);
                while (sr.Peek() > -1)
                {
                    string item = sr.ReadLine();
                    int index = item.IndexOf("=");
                    if (index > -1)
                        Config.Add(item.Substring(0, index).ToLower(), item.Substring(index + 1));
                }
                
                StartTime = Convert.ToInt32(Config["starthours"]);
                EndTime = Convert.ToInt32(Config["endhours"]);
                if (!string.IsNullOrEmpty(Config["contentpicnum"].Trim()))
                    ContentPicNum = Convert.ToInt32(Config["contentpicnum"].Trim()); 
            }
            catch (Exception ex)
            {
            }
        }
        public static bool WorkTime()
        {
            if (Debugger.IsAttached) return true;
          return  StringUtils.IsDoWork(StartTime, EndTime);
        }

    }
}
